//
//  TCWindow.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/3/12.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class TCWindow: NSWindow {
    
    override init(contentRect: NSRect, styleMask style: NSWindow.StyleMask, backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool) {
        super.init(contentRect: contentRect, styleMask: style, backing: backingStoreType, defer: flag)
        self.collectionBehavior = NSWindow.CollectionBehavior.fullScreenPrimary
        //设置圆角
        self.contentView?.layer?.masksToBounds = true
        self.contentView?.layer?.cornerRadius = 5
        self.contentView?.wantsLayer = true
        self.backgroundColor = NSColor.clear
        //self.animationBehavior = .alertPanel
        
        self.isMovable = true
        self.isMovableByWindowBackground = false
        self.hasShadow = true
        //self.titlebarAppearsTransparent = true
        //self.titleVisibility = .hidden
        self.styleMask = [.titled,.closable,.miniaturizable,.resizable]
        //self.standardWindowButton(NSWindow.ButtonType.zoomButton)?.isHidden = true
        self.re_SELF_button()
    }
    
    func re_SELF_button() {
        self.closeButton.action = #selector(closeBtnAction)
        //self.zoomButton.action = #selector(zoomBtnAction)
        //self.miniaturizeButton.action = #selector(minBtnAction)
    }
    
    lazy var closeButton: NSButton = {
        let btn = self.standardWindowButton(NSWindow.ButtonType.closeButton)
        btn?.target = self
        return btn!
    }()
    
    lazy var zoomButton: NSButton = {
        let btn = self.standardWindowButton(NSWindow.ButtonType.zoomButton)
        btn?.target = self
        return btn!
    }()
    
    lazy var miniaturizeButton: NSButton = {
        let btn = self.standardWindowButton(NSWindow.ButtonType.miniaturizeButton)
        btn?.target = self
        return btn!
    }()
    
    @objc func closeBtnAction() {
        AsSheet.exitRoom()
    }
    @objc func zoomBtnAction() {
        
    }
    
    @objc func minBtnAction() {
        
    }
    
}
